package com.lj.graduate.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lj.graduate.common.Result;
import com.lj.graduate.controller.dto.FeedbackDTO;
import com.lj.graduate.controller.dto.OrderDTO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.lj.graduate.service.IFeedbackService;
import com.lj.graduate.entity.Feedback;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ljy
 * @since 2023-03-24
 */
@RestController
@RequestMapping("/feedback")
        public class FeedbackController {
    
@Resource
private IFeedbackService feedbackService;

// 新增或者更新
@PostMapping
public boolean save(@RequestBody Feedback feedback) {
        return feedbackService.saveOrUpdate(feedback);
        }

@DeleteMapping("/{id}")
public Boolean delete(@PathVariable Integer id) {
        return feedbackService.removeById(id);
        }

@PostMapping("/del/batch")
public boolean deleteBatch(@RequestBody List<Integer> ids) {
        return feedbackService.removeByIds(ids);
        }

@GetMapping
public List<Feedback> findAll() {
        return feedbackService.list();
        }

@GetMapping("/{id}")
public Feedback findOne(@PathVariable Integer id) {
        return feedbackService.getById(id);
        }

//@GetMapping("/page")
//public Page<Feedback> findPage(@RequestParam Integer pageNum,
//@RequestParam Integer pageSize) {
//        QueryWrapper<Feedback> queryWrapper = new QueryWrapper<>();
////        queryWrapper.orderByDesc("id");
//        return feedbackService.page(new Page<>(pageNum, pageSize), queryWrapper);
//        }
@GetMapping("/page")
public Result selectPage(@RequestParam Integer pageNum,
                         @RequestParam Integer pageSize
){
        pageNum = (pageNum - 1) * pageSize;
        List<FeedbackDTO> sysUserIPage = feedbackService.selectPage(pageNum,pageSize);

        return Result.success(sysUserIPage);


}
        }

